import argparse


def wc():
    parser = argparse.ArgumentParser(description='wc 文件行数 字符数统计 ')
    parser.add_argument('-f', '--file', nargs='?', default='', help='文件')
    args, unknown_args = parser.parse_known_args()
    file_path = args.file
    if len(file_path.strip()) == 0 and len(unknown_args) > 0:
        file_path = unknown_args[0]
    lines = 0
    chars = 0
    words = 0
    with open(file_path, mode="r", encoding="utf-8") as f:
        for line in f:
            lines += 1
            chars += len(line.replace(' ', '').replace('\n', ''))
            words += len(line.split())
    print(f'''
    行数: {lines}
    字符数: {chars}
    单词数: {words}
    ''')


if __name__ == '__main__':
    wc()
